home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-07-16 | 5.4 KB | 195 lines | [TEXT/CWIE] |
- // ===========================================================================
- // CEvalDialog.cp ©1995-97 Timo Eloranta All rights reserved.
- // ===========================================================================
-
- #include "CEvalDialog.h"
- #include "GraphGA_PaneIDs.h"
-
- #include <LGAEditField.h>
- #include <LGAPushButton.h>
- #include <LGACheckbox.h>
-
- #include <PP_Messages.h>
- #include <UReanimator.h>
- #include <UDesktop.h>
-
- // ---------------------------------------------------------------------------
- // • CEvalDialog
- //
- // Called by: URegistrar::CreateObject
- // ---------------------------------------------------------------------------
-
- CEvalDialog::CEvalDialog( LStream *inStream )
- : LGADialogBox( inStream )
- {
- }
-
- // ---------------------------------------------------------------------------
- // • InitDialog
- //
- // Called by: CGraphGAApp::ObeyCommand
- // ---------------------------------------------------------------------------
-
- void
- CEvalDialog::InitDialog()
- {
- mFactoryButton = (LGAPushButton *) this -> FindPaneByID( but_FactorySettings );
-
- mCrossingsBox = (LGACheckbox *) this -> FindPaneByID( cbox_CrossingsRule );
-
- UReanimator::LinkListenerToControls( this, this, WIND_Evaluate );
-
- mEdit1 = (LGAEditField *) this -> FindPaneByID( edit_1 );
- mEdit2 = (LGAEditField *) this -> FindPaneByID( edit_2 );
- mEdit3 = (LGAEditField *) this -> FindPaneByID( edit_3 );
- mEdit4 = (LGAEditField *) this -> FindPaneByID( edit_4 );
- mEdit5 = (LGAEditField *) this -> FindPaneByID( edit_5 );
- mEdit6 = (LGAEditField *) this -> FindPaneByID( edit_6 );
- mEdit7 = (LGAEditField *) this -> FindPaneByID( edit_7 );
- }
-
- // ---------------------------------------------------------------------------
- // • SetValues
- //
- // Called by: CGraphGAApp::ObeyCommand
- // ---------------------------------------------------------------------------
-
- void
- CEvalDialog::SetValues( SEvaluation &inEval )
- {
- mCrossingsBox -> SetValue( inEval.crossingsRule );
-
- mEdit1 -> SetValue( inEval.multip1 );
- mEdit2 -> SetValue( inEval.multip2 );
- mEdit3 -> SetValue( inEval.multip3 );
- mEdit4 -> SetValue( inEval.multip4 );
- mEdit5 -> SetValue( inEval.multip5 );
- mEdit6 -> SetValue( inEval.multip6 );
- mEdit7 -> SetValue( inEval.multip7 );
-
- mEdit1 -> SelectAll();
- SetLatentSub( mEdit1 );
-
- AdjustFactoryButton();
- }
-
- // ---------------------------------------------------------------------------
- // • SetDefaultValues (PRIVATE)
- //
- // Called by: CEvalDialog::ListenToMessage
- // ---------------------------------------------------------------------------
-
- void
- CEvalDialog::SetDefaultValues( )
- {
- mCrossingsBox -> SetValue( DEFAULT_CROSSINGS_RULE );
-
- mEdit1 -> SetValue( DEFAULT_MULTIP_1 );
- mEdit2 -> SetValue( DEFAULT_MULTIP_2 );
- mEdit3 -> SetValue( DEFAULT_MULTIP_3 );
- mEdit4 -> SetValue( DEFAULT_MULTIP_4 );
- mEdit5 -> SetValue( DEFAULT_MULTIP_5 );
- mEdit6 -> SetValue( DEFAULT_MULTIP_6 );
- mEdit7 -> SetValue( DEFAULT_MULTIP_7 );
- }
-
- // ---------------------------------------------------------------------------
- // • GetValues
- //
- // Called by: CGraphGAApp::SetEvalFromDialog
- // ---------------------------------------------------------------------------
-
- void
- CEvalDialog::GetValues( SEvaluation &outEval )
- {
- Boolean theZeros = false;
- Int16 theTemp;
-
- outEval.crossingsRule = mCrossingsBox -> GetValue();
-
- outEval.multip1 = mEdit1 -> GetValue();
- outEval.multip2 = mEdit2 -> GetValue();
- outEval.multip3 = mEdit3 -> GetValue();
- outEval.multip6 = mEdit6 -> GetValue();
-
- theTemp = mEdit4 -> GetValue();
- if ( theTemp ) outEval.multip4 = theTemp;
- else theZeros = true;
-
- theTemp = mEdit5 -> GetValue();
- if ( theTemp ) outEval.multip5 = theTemp;
- else theZeros = true;
-
- theTemp = mEdit7 -> GetValue();
- if ( theTemp ) outEval.multip7 = theTemp;
- else theZeros = true;
-
- if ( theZeros ) {
- UDesktop::Deactivate();
- ::StopAlert( ALRT_DivideByZero, nil );
- UDesktop::Activate();
- }
- }
-
- // ---------------------------------------------------------------------------
- // • ListenToMessage
- //
- // Called by: LBroadcaster::BroadcastMessage
- // ---------------------------------------------------------------------------
-
- void
- CEvalDialog::ListenToMessage(
- MessageT inMessage,
- void *ioParam )
- {
- switch ( inMessage ) {
-
- case msg_CrossingsRule: // msg from mCrossingsBox
- AdjustFactoryButton();
- break;
-
- case msg_FactorySettings: // msg from mFactoryButton
- SetDefaultValues( );
- break;
-
- default:
- LGADialogBox::ListenToMessage( inMessage, ioParam );
- break;
- }
- }
-
- // ---------------------------------------------------------------------------
- // • AdjustFactoryButton (PRIVATE)
- //
- // Called by: CEvalDialog::SetValues
- // CEvalDialog::ListenToMessage
- // ---------------------------------------------------------------------------
-
- void
- CEvalDialog::AdjustFactoryButton( )
- {
- if ( ! mFactoryButton -> IsEnabled() )
- mFactoryButton -> Enable();
- }
-
- // ---------------------------------------------------------------------------
- // • FindCommandStatus
- //
- // Called by: LCommander::ProcessCommandStatus
- // ---------------------------------------------------------------------------
- // Disable all menu items except for the one which opens the About box.
-
- void
- CEvalDialog::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean& /* outUsesMark */,
- Char16& /* outMark */,
- Str255 /* outName */)
- {
- outEnabled = false;
- if (inCommand == cmd_About) {
- outEnabled = true;
- }
- }
-